package com.yantu.controller.student;

import com.yantu.bean.ClassStudent;
import com.yantu.mapper.ClassStudentMapper;
import com.yantu.util.Result;
import com.yantu.view.student.StudentJoinClassView;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@ApiModel("学生加入班级接口信息")
@RequestMapping("/student")
public class StudentJoinClassController {
    @Autowired
    ClassStudentMapper classStudentMapper;


    @PostMapping("/joinClass")
    @ApiOperation("学生加入班级")
    public Result studentPaper(@RequestBody StudentJoinClassView studentJoinClassView) {

        ClassStudent classStudent = new ClassStudent();
        classStudent.setClassId(studentJoinClassView.getCId());
        classStudent.setUserId(studentJoinClassView.getUId());
        java.util.Date  date=new java.util.Date();
        java.sql.Date  sqldate=new java.sql.Date(date.getTime());
        classStudent.setCreateTime(sqldate);
        classStudentMapper.insert(classStudent);
        return Result.succ(200, "加入班级成功",null);

    }

}
